﻿using MailDAL;
using MailTool.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MailTool
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            UnitOfWork unitOfWork = new UnitOfWork();
            MailModel.User user = new MailModel.User();
            user.UserName = txtUserName.Text.Trim();
            user.Password = DEncrypt.md5(txtPassword.Text.Trim(), 32);
            user.Mail = txtMail.Text.Trim();
            user.CreateDate = DateTime.Now;
            unitOfWork.UserRepository.Insert(user);
            unitOfWork.Save();

            SessionState.CurrentUser = user;

            JsUtil.AlertAndRedirect("注册成功~！", "Index.aspx", this.Page);
        }
    }
}